<html>
<head><meta charset="utf-8"><title>Representation of union · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html">Representation of union</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223783022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223783022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> HeroicKatora <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223783022">(Jan 23 2021 at 23:04)</a>:</h4>
<p>It's a bit surprising that <code>union</code> is the one <code>ItemKind</code> that shares its <code>ItemEnum</code> with another, with <code>struct</code>. Even more since <code>unions</code> do not permit all the <code>StructType</code> variants.</p>



<a name="223783046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223783046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> HeroicKatora <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223783046">(Jan 23 2021 at 23:04)</a>:</h4>
<p>Is that due to implementation details, struct and union share a lot of code in the compiler? Not sure if I'm remembering this correctly.</p>



<a name="223783436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223783436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223783436">(Jan 23 2021 at 23:14)</a>:</h4>
<p><span class="user-mention" data-user-id="229913">@HeroicKatora</span> I think <span class="user-mention" data-user-id="319144">@CraftSpider</span> is planning to fix that</p>



<a name="223783439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223783439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223783439">(Jan 23 2021 at 23:14)</a>:</h4>
<p>And remove the StructType fields</p>



<a name="223786151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223786151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223786151">(Jan 24 2021 at 00:17)</a>:</h4>
<p>As of the merge removing <code>doctree::StructType</code>, unions display as 'kind: struct, struct_type: union' (Before, there was no differentiation at all). Now that StructType has been removed, it would be nice to fix that, and I'll probably make a PR to do so soon. I just didn't want to mess with it in the same PR</p>



<a name="223786201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223786201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223786201">(Jan 24 2021 at 00:18)</a>:</h4>
<p>New style would be 'kind: union' with no struct_type, so unions are actually a proper type of their own</p>



<a name="223786631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223786631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223786631">(Jan 24 2021 at 00:30)</a>:</h4>
<p>Actually, sorry, it is tagged as kind: union already I think. I was confused by it sharing a type, but the ItemKind is different it looks like. So splitting it only removes the redundant struct_type field</p>



<a name="223786661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223786661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> HeroicKatora <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223786661">(Jan 24 2021 at 00:31)</a>:</h4>
<p>It is already? Okay, I should probably update my nightly then.</p>



<a name="223786773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Representation%20of%20union/near/223786773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Representation.20of.20union.html#223786773">(Jan 24 2021 at 00:34)</a>:</h4>
<p>To clarify: Before any of my changes, unions <em>should</em> be <code>kind: union</code>, if they are appearing as <code>kind: struct</code> currently that's a bug as ItemKind already has a Union type. The only difference from my change would be the value of <code>struct_type</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>